package com.mkyong.client;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;

public class SOAPMsg2 {

	/**
	 * @param args
	 * @throws SOAPException 
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 */
	public static void main(String[] args) throws FileNotFoundException, IOException, SOAPException {
		URL url = new URL("http://localhost:8888/ws/hello?wsdl");
	    QName serviceName = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
	    QName portName = new QName("http://ws.mkyong.com/", "HelloWorldImplPort");
	    Service service = Service.create(url, serviceName);
	    Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class,
	        Service.Mode.MESSAGE);

	    MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage message = messageFactory.createMessage();

	    message.writeTo(System.out);
	    
	}

}
